<?php
	if ( isCached() )
		return;

	$onehour = date("D, j M Y H:i:s T",time()  + 60 * 60);
	header("Content-disposition: attachment; filename=bbs2.js");
	header("Expires: $onehour" ,true);
	header("Last-Modified: ". date("D, j M Y H:i:s T") ,true);
	header("Content-Type: text/javascript; charset=UTF-8",true);
	header("Cache-Control: max-age=315360000",true);
	header("Age: 87000",true);


	function isCached ()
	{
		$tmp = getRequestHeader("HTTP_PRAGMA");
		if ( strcasecmp($tmp,"no-cache") == 0  )
		{
			return false;
		}

		$tmp = getRequestHeader("HTTP_CACHE_CONTROL");
		if ( strcasecmp($tmp,"no-cache") == 0  )
		{
			return false;
		}

		$tmp = getRequestHeader("HTTP_IF_MODIFIED_SINCE" );
		if (!is_null ($tmp))
		{
			header ("HTTP/1.0 304 Not Modified", true, 304);
			return true;
		}
		else
			return false;
	}

	function getRequestHeader($name)
	{
		if ( ! array_key_exists($name,$_SERVER))
			return null;
		return trim($_SERVER[$name]);
	}
	
?>var bbs2_ad="www.6kbbs.com";